﻿@{
    ViewBag.Title = "个人文档中心查询";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@section scripts{
        <script src="~/Areas/Qms/ViewModels/qms.viewModel.search.js"></script>
        <script type="text/javascript">
            var data = @Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(Model));
            var viewModel = function(data){ 
                var self = this;
                qms.viewModel.search.apply(self,arguments);
                //阅读

                this.readClick = function()
                {
                    var row = self.grid.datagrid('getSelected');
                    if (!row) return com.message('warning', "确认要标识选中的记录吗?");
                        com.message('confirm', self.resx.deleteConfirm, function (b) {
                            if (b) {
                                com.ajax({
                                    type: 'POST', 
                                    url: "/api/qms/FileContent/UserFileListRead/" + row[self.idField], 
                                    success: function () {
                                        com.message('success', "标识成功!");
                                        self.searchClick();
                                     }
                            });
                         }
                    });
                }
            } 
            ko.bindingViewModel(new viewModel(data));

            var formatterPermit = function (value, row) {
                var Bh =  row["FileAttachment_FileBh"] + '|'+row["FileAttachment_RowId"];
                var html ='<a href="/qms/FileContent/DownLoad?id=' + Bh + '"+  style="margin-left:2px"><span class="icon icon-download ">&nbsp;</span>[下载]&nbsp&nbsp</a><br>';
                return html;
            };
           var formatterPic = function(value,row){
                var html = "";
                if (row["IsRead"] == 0 ) 
                    html = '<a href="#"  style="margin-left:2px"><span class="icon icon-new ">&nbsp;</span>[标识]</a>';
                else
                    html = '<a href="#"  style="margin-left:2px"><span class="icon icon-new_blue">&nbsp;</span>[标识]</a>';
                return html;
            }

        </script>
}
        <div class="z-toolbar">
            <a id="a_refresh" href="#" plain="true" class="easyui-linkbutton" icon="icon-arrow_refresh" title="刷新" data-bind="click:refreshClick">刷新</a>
            <a id="a_del" href="#" plain="true" class="easyui-linkbutton" icon="icon-cross" title="删除" data-bind="click:deleteClick">删除</a> 
            <a id="a_publish" href="#" plain="true" class="easyui-linkbutton" icon="icon-accept" title="处理" data-bind="click:readClick">处理</a> 
        </div>
        <div id="condition" class="container_12" style="position:relative;">
            <div class="grid_1 lbl">文档名称</div>
            <div class="grid_2 val"><input type="text" data-bind="value:form.FileContent_Title" class="z-txt"/></div>
            <div class="grid_1 lbl">发布人员</div>
            <div class="grid_2 val"><input type="text" data-bind="value:form.PublishUser" class="z-txt"/></div>
            <div class="grid_1 lbl">处理标识</div>
            <div class="grid_2 val"><input type="text" data-bind="datasource:dataSource.yesnoItems ,comboboxValue:form.IsRead" class="z-txt easyui-combobox" data-options="showblank:true"/></div>
            <div class="clear"></div>
            <div class="grid_1 lbl">发布日期</div>
            <div class="grid_2 val"><input type="text" data-bind="value:form.CreateTime" class="z-txt easyui-daterange"/></div>
            <div class="grid_1 lbl">有效日期</div>
            <div class="grid_2 val"><input type="text" data-bind="value:form.FileContent_ValidDate" class="z-txt easyui-daterange"/></div>
            <div class="clear"></div>

            <div class="prefix_9" style="position:absolute;top:5px;height:0;">  
                <a id="a_search" href="#" class="button button-blue" style="margin:0 15px;" data-bind="click:searchClick">查询</a> 
                <a id="a_reset" href="#" class="button button-blue" data-bind="click:clearClick">清空</a>
            </div>
        </div>
        <table id="gridlist" data-bind="datagrid:grid"  >
             <thead>  
                <tr>  
                    <th field="ck" checkbox="true"></th>
                    <th field="IsRead"         sortable="true" align="left" formatter="formatterPic"   width="80"  >标识</th>  
                    <th field="UserCode"         sortable="true" align="left"    width="80"  >人员编号</th>  
                    <th field="FileContent_Title"           sortable="true" align="left"    width="160"  >文档名称</th>  
                    <th field="FileAttachment_FullName"     sortable="true" align="left"    width="260"  >附件名称</th>  
                    <th field="Permit" align="left" width="90" formatter="formatterPermit">操作</th>
                    <th field="FileAttachment_FileBh"       sortable="true" align="left"    width="100"  >附件编号</th>  
                    <th field="FileAttachment_RowId"        sortable="true" align="left"    width="80"  >附件行号</th>  
                    <th field="PublishUser"        sortable="true" align="left"    width="50"  >发布人</th> 
                    <th field="FileContent_IsPublic"        sortable="true" align="center"  formatter="com.formatCheckbox"   width="50"  >是否公开</th> 
                    <th field="FileContent_ValidDate"       sortable="true" align="center"  formatter="com.formatDate"    width="80" >有效日期</th>
                    <th field="ReadTime"                    sortable="true" align="center"  formatter="com.formatDate"    width="80" >创建日期</th>   
                </tr>                            
            </thead>      
        </table> 
